<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" name="username" id="username"/>
    <input type="file" name="file1" id="file1" />
    <button id="btn">提交</button>
</body>
<script>

    btn.onclick = function () {
        var file1 = document.getElementById('file1')
        var btn = document.getElementById('btn')
        var username=document.getElementById('username')
        var formData = new FormData()
        formData.append("username",username.value)
        formData.append("myimg", file1.files[0])
        fetch('http://localhost:8081/upload', {
            method: 'PUT',
            body: formData
        }).then(res => res.text())
            .then(res => console.log(res))
    }
</script>

</html>